package com.daiyang.campus_lucky_draw.common.exception;

import com.daiyang.campus_lucky_draw.common.error.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class ServiceException extends RuntimeException {
    /**
     * 业务错误码
     * @see com.daiyang.campus_lucky_draw.common.error.ServiceErrorCodeConstants
     */
    private int code;
    private String message;
    /**
     * 空构造⽅法，避免反序列化问题
     */
    public ServiceException() {

    }
    public ServiceException(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.message = errorCode.getMsg();
    }
    //自定义异常
    public ServiceException(ErrorCode errorCode, String message) {
        this.code = errorCode.getCode();
        this.message = message;
    }
}
